# 发送邮件的异步任务/函数
from django.core.mail import send_mail
from django.conf import settings

from celery_tasks.main import celery_app


@celery_app.task(name="send_verify_email") # name是别名可选)
def sen_verify_email(to_email,verify_url):
    """发送验证邮件的异步任务"""
    # 邮件标题
    subject = "美多商城"

    # 邮件附文本
    subject = "美多商城邮箱验证"
    html_message = '<p>尊敬的用户您好！</p>' \
                   '<p>感谢您使用美多商城。</p>' \
                   '<p>您的邮箱为：%s 。请点击此链接激活您的邮箱：</p>' \
                   '<p><a href="%s">%s<a></p>' % (to_email, verify_url, verify_url)

    # send_mail("标题","邮件正文:普通文本,text/plain","发件人","收件人列表",html_message="邮件正文")
    send_mail(subject,"I LOVE U",settings.EMAIL_FROM,[to_email],html_message=html_message)
